package com.woniuxy.bookmall.service;

import com.woniuxy.bookmall.entity.TUser;
import com.woniuxy.bookmall.mapper.TUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserService {
    @Autowired
    TUserMapper userMapper ;

    public TUser login(String username, String password) {
        return userMapper.selectUserByNameAndPass(username,password);
    }

    public TUser findUserByEmail(String email) {
        return userMapper.selectUserByEmail(email);
    }

    public void register(String email, String password) {
        TUser user = new TUser();
        user.setAccount("aaaaaa");
        user.setCreatetime(new Date());
        user.setEmail(email);
        user.setPassword(password);
        user.setState(1);
        userMapper.insert(user);
    }
}
